<?php
// ------------------------------------------------------------------
// NEEDED STUBS FOR THIS EXAMPLE
// ------------------------------------------------------------------


// this will include all needed files to be able to build a Request
include_once($CONF["STUBS_FOLDER"]."Map24Geocoder51/Map24Geocoder51.php5");


// ------------------------------------------------------------------
// NEEDED PARAMETERS FOR THIS REQUEST
// ------------------------------------------------------------------


// the address to geocode
$searchText = "Freiburg";

// the number of alternatives to display
$maxNoOfAlternatives = 10;


// ------------------------------------------------------------------
// BUILDING THE REQUEST
// ------------------------------------------------------------------


// definition of the request header with Map24ID and SessionID
$header = new RequestHeader();
$header->Map24ID  = $CONF['MAP24_ID'];
$header->ClientID = $CONF['SESSION_ID'];

// definition of the request body
$request = new MapSearchFreeRequest();
$request->SearchText = $searchText;
$request->MaxNoOfAlternatives = $maxNoOfAlternatives;


// ------------------------------------------------------------------
// EXECUTE THE REQUEST
// ------------------------------------------------------------------


// in this object the SoapClient will be initiated and executed
$geocoder = new Map24Geocoder51($CONF['MAPTP_SYSTEM'],$CONF['MAP24_ID'],$CONF['SESSION_ID']);
$response = $geocoder->searchFree($header,$request);


// ------------------------------------------------------------------
// OUTPUT THE RESULT
// ------------------------------------------------------------------


if(isset($response->Alternatives) && count($response->Alternatives) > 0)
{
	foreach ($response->Alternatives as $result)
	{
		$counter++;
		$resultString .= "<div>".$counter.". ";

		foreach ($result->PropertiesMajor as $property)
		{
			$resultString .= $property->Value." ";
		}

		$resultString .= "</div>";
	}
}
else
{
	$resultString = "Sorry, no results found for \"".$searchText."\"";
}


?>